package com.yitiao.data_algorithms.leetcode.editor.cn;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

class RemoveDuplicatesFromSortedArrayIi{
    // 2022-08-23 13:49:20
    public static void main(String[] args) {
        Solution solution = new RemoveDuplicatesFromSortedArrayIi().new Solution();
    }
    
    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int removeDuplicates(int[] nums) {
            int head = 0, tail = 0;
            while (head < nums.length) {
                if (2 > tail || nums[tail - 2] != nums[head]) {
                    nums[tail++] = nums[head];
                }
                head++;
            }
            return tail;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}